<template>
  <div class="layout-container">
    <el-header class="header">
      <div class="bb">品优购电商后台</div>
      <el-button @click="logout">退出登录</el-button>
    </el-header>
    <el-container>
      <el-aside :width="collapse ? '60px' : '200px'">
        <el-menu
          @close="handleClose"
          @open="handleOpen"
          active-text-color="hotpink"
          background-color=" #313a46"
          class="el-menu-vertical-demo"
          :default-active="$route.path"
          :router="true"
          text-color="#fff"
        >
          <el-menu-item>
            <i @click="collapse = !collapse" class="el-icon-menu"></i>
          </el-menu-item>
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>用户管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/userList">用户列表</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>权限管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/userQxList">角色列表</el-menu-item>
              <el-menu-item index="/qxList">权限列表</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>商品管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/goods">商品列表</el-menu-item>
              <el-menu-item index="1-1">选项1</el-menu-item>
              <el-menu-item index="1-1">选项1</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>订单管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/indent">订单列表</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="5">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>数据统计</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/reports">数据报表</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-container>
        <!-- <el-card> -->
        <el-main>
          <router-view></router-view>
        </el-main>
        <!-- </el-card> -->
      </el-container>
    </el-container>
  </div>
</template>
<script>
import { listApi } from '@/api/user'
export default {
  name: 'layout',
  data () {
    return {
      collapse: false,
    }
  },
  async created () {
    const res = await listApi()
    console.log(res, 888888)

  },
  computed: {
  },
  methods: {
    handleOpen (key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose (key, keyPath) {
      console.log(key, keyPath);
    },
    logout () {
      //干掉token 然后 回 login 
      this.$store.commit('user/resetToken')
      this.$router.push('/login')
    }
  }
}
</script>
<style lang='scss'  scoped>
.layout-container {
  .header {
    background-color: #313a46;
    display: flex;
    .bb {
      font-size: 26px;
      width: 100%;
      text-align: center;
      line-height: 80px;
      height: 80px;
      color: #fff;
      font-weight: 700;
    }
  }

  height: 100vh;
  .el-container {
    height: 100vh;
    .el-aside {
      background-color: #313a46;
    }
  }
}
</style>

